package com.autumn.runtime.exception.filter;

import org.springframework.core.annotation.Order;

import com.autumn.common.api.web.vo.ErrorInfoResult;
import com.autumn.util.ErrorLevel;
import com.autumn.util.IAutumnError;

/**
 * 默认最后异常过滤
 * 
 * @author 杨昌国 2018-12-07 02:25:06
 */
@Order(Integer.MAX_VALUE)
public class DefaultLastExceptionFilter extends AbstractExceptionFilter {

	@Override
	protected ErrorInfoResult doInternalFilter(Throwable e) {
		if (e instanceof IAutumnError) {
			IAutumnError autumnError = (IAutumnError) e;
			return new ErrorInfoResult(!ErrorLevel.USER.equals(autumnError.getLevel()), e, autumnError.getCode(),
					e.getMessage(), "");

		}
		return new ErrorInfoResult(true, e, 0, e.getMessage(), "");
	}

}
